﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnDaPPE
{
    public class PcToPlc
    {
        PlcController _plc;

        public PcToPlc(PlcController plcInstance)
        {
            _plc = plcInstance;
        }
        //plc心跳信号
        private short _watchDog10;
        private short _watchDog20;
        private short _watchDog30;
        //发给plc扫码完成信号
        private int _uploadDoneOP10Left;
        private int _uploadDoneOP10Right;
        private int _uploadDoneOP20;
        private int _uploadDoneOP30;
        //发给plc加工完成信号
        private int _uploadworkDoneOP10Left;
        private int _uploadworkDoneOP10Right;
        private int _uploadworkDoneOP20;
        private int _uploadworkDoneOP30;
        //允许加工信号
        private int _allowOP10Left;
        private int _allowOP10Right;
        private int _allowOP20;
        private int _allowOP30;
        #region 心跳信号
        /// <summary>
        /// 心跳plcop10左工位
        /// </summary>
        public short WatchDog10
        {
            get
            {
                return _watchDog10;
            }
            set
            {
                _watchDog10 = value;
                _plc.WriteInt("DB1000.DBW0", _watchDog10);
            }
        }
       
        /// <summary>
        /// 心跳plcop20
        /// </summary>
        public short WatchDog20
        {
            get
            {
                return _watchDog20;
            }
            set
            {
                _watchDog20 = value;
                _plc.WriteInt("DB1000.DBW0", _watchDog20);
            }
        }
        /// <summary>
        /// 心跳plcop30
        /// </summary>
        public short WatchDog30
        {
            get
            {
                return _watchDog30;
            }
            set
            {
                _watchDog30 = value;
                _plc.WriteInt("DB1000.DBW0", _watchDog30);
            }
        }
        #endregion

        #region 给PLC完成信号扫码完成
        /// <summary>
        /// 上传完成OP10左工位
        /// </summary>
        public int UploadScanDoneOP10Left
        {
            get
            {
                return _uploadDoneOP10Left;
            }
            set
            {

                _uploadDoneOP10Left = value;
                _plc.WriteInt("DB1001.DBW6", (short)_uploadDoneOP10Left);

            }
        }
        /// <summary>
        /// OP10右工位
        /// </summary>
        public int UploadScanDoneOP10Right
        {
            get
            {
                return _uploadDoneOP10Right;
            }
            set
            {
                _uploadDoneOP10Right = value;
                _plc.WriteInt("DB1001.DBW6", (short)_uploadDoneOP10Right);
            }
        }
        /// <summary>
        /// OP20完成信号
        /// </summary>
        public int UploadScanDoneOP20
        {
            get
            {
                return _uploadDoneOP20;
            }
            set
            {
                _uploadDoneOP20 = value;
                _plc.WriteInt("DB1001.DBW6", (short)_uploadDoneOP20);
            }
        }

        /// <summary>
        /// OP30完成信号
        /// </summary>
        public int UploadScanDoneOP30
        {
            get
            {
                return _uploadDoneOP30;
            }
            set
            {
                _uploadDoneOP30 = value;
                _plc.WriteInt("DB1001.DBW6", (short)_uploadDoneOP30);
            }
        }
        #endregion

        #region 给PLC信号数据上传完成
        /// <summary>
        /// 上传完成OP10左工位
        /// </summary>
        public int UploadDoneWorkOP10Left
        {
            get
            {
                return _uploadworkDoneOP10Left;
            }
            set
            {

                _uploadworkDoneOP10Left = value;
                _plc.WriteInt("DB1000.DBW2", (short)_uploadworkDoneOP10Left);

            }
        }
        /// <summary>
        /// OP10右工位
        /// </summary>
        public int UploadDoneWorkOP10Right
        {
            get
            {
                return _uploadworkDoneOP10Right;
            }
            set
            {
                _uploadworkDoneOP10Right = value;
                _plc.WriteInt("DB1000.DBW2", (short)_uploadworkDoneOP10Right);
            }
        }
        /// <summary>
        /// OP20数据上传完成信号
        /// </summary>
        public int UploadWorkDoneOP20
        {
            get
            {
                return _uploadworkDoneOP20;
            }
            set
            {
                _uploadworkDoneOP20 = value;
                _plc.WriteInt("DB1000.DBW2", (short)_uploadworkDoneOP20);
            }
        }

        /// <summary>
        /// OP30数据上传完成信号
        /// </summary>
        public int UploadWorkDoneOP30
        {
            get
            {
                return _uploadworkDoneOP30;
            }
            set
            {
                _uploadworkDoneOP30 = value;
                _plc.WriteInt("DB1000.DBW2", (short)_uploadworkDoneOP30);
            }
        }
        #endregion

        #region 允许加工
        /// <summary>
        /// 允许op10左工位工作
        /// </summary>
        public int AllowOP10Left
        {
            get
            {
                return _allowOP10Left;
            }
            set
            {
                _allowOP10Left = value;
                _plc.WriteInt("DB1000.DBW8", (short)_allowOP10Left);
            }
        }
        /// <summary>
        /// 允许op10右工位工作
        /// </summary>
        public int AllowOP10Right
        {
            get
            {
                return _allowOP10Right;
            }
            set
            {
                _allowOP10Right = value;
                _plc.WriteInt("DB1000.DBW8", (short)_allowOP10Right);
            }
        }
        /// <summary>
        /// 允许op20工位工作
        /// </summary>
        public int AllowOP20
        {
            get
            {
                return _allowOP20;
            }
            set
            {
                _allowOP20 = value;
                _plc.WriteInt("DB1000.DBW8", (short)_allowOP20);
            }
        }

        /// <summary>
        /// 允许op30工位工作
        /// </summary>
        public int AllowOP30
        {
            get
            {
                return _allowOP30;
            }
            set
            {
                _allowOP30 = value;
                _plc.WriteInt("DB1000.DBW8", (short)_allowOP30);
            }
        }
        #endregion


    }

}
